--[[ 编码: JX-300-04 名称: WCS->WMS 料箱扫码入库 作者:HAN 日期:2025-1-29 级别:项目 函数: BoxStorage WCS 这边的输入参数 { "requestPk": "pk2022120614242376", "containerCode": "60001", "curPos": "15021" "taskNo": "xxxx" } 功能: -- WCS 在料箱过扫码点的时候触发 -- 判断容器是否有在【巨星任务】,如果有创建的是一个【巨星入库】作业 -- 判断是否是巨沃的入库作业 更改记录: V2.0 HAN 20241207 -- 取消料箱初始化入库 V3.0 HAN 20241209 V4.0 HAN 20241217 + 对JW_CNTR_Goods_INIT的处理 + 对O23,M24为目的地的 巨星入库任务的处理 V5.0 HAN 20241219 对已经启动了作业的容器特别处理 V6.0 HAN 20241225 在扫码前先判断一下堆垛机的状态 V7.0 HAN 20241229 巨星出库任务没指定出库货位的要根据库区的任务数量做均衡 V7.1 HAN 20241230 加改进任务巷道信息 V8.0 HAN 20250218 JX_Task里新增来源巨沃的码盘入库任务 --V20250315-- --]] wms_cntr = require( "wms_container" ) wms_op = require( "wms_operation" ) wms_task = require( "wms_task" ) jx_base = require( "jx_base" ) wms_wh = require( "wms_wh" ) local CAN_TO_3_4_FLOOR_STATION = "16120" local AREA_3_FLOOR = "L24" local AREA_4_FLOOR = "M23" local LOC_3_FLOOR = "L812301" local LOC_4_FLOOR = "L812401" -- 合并CG_Detail明细 local function CG_detail_Merge(strLuaDEID, cntr_code) local result = { success = true, errMsg = "" } -- 查询 JX_Transfer_Order 表,检查是否存在 N_B_STATE 为 0 的记录 strCondition = "S_CNTR_CODE = '" .. cntr_code .. "'" nRet, cntr_list = m3.QueryDataObject(strLuaDEID, "JX_Transfer_Order", strCondition) lua.Debug(strLuaDEID, debug.getinfo(1), "cntr_list--->", cntr_list) -- 检查查询是否成功 if (nRet ~= 0) then result.success = false result.errMsg = "查询 JX_Transfer_Order 表失败!" lua.Warning(strLuaDEID, debug.getinfo(1), "查询失败: " .. result.errMsg) return 200, result.errMsg end -- 如果查询到数据,则进行循环判断 if cntr_list and #cntr_list > 0 then for i = 1, #cntr_list do local order_attrs = m3.KeyValueAttrsToObjAttr(cntr_list[i].attrs) local b_state = order_attrs.N_B_STATE if (b_state == '0') then result.success = false result.errMsg = "容器号 " .. cntr_code .. " 存在 N_B_STATE 为 0 的记录,操作中止!" lua.Warning(strLuaDEID, debug.getinfo(1), "查询失败: " .. result.errMsg) return 200, result.errMsg end end end -- 查询 JX_TO_Detail 表 local container_data, nRet local strCondition = "S_TO_NO IN (SELECT S_NO FROM TN_JX_Transfer_Order WHERE S_CNTR_CODE = '" .. cntr_code .. "' AND N_B_STATE = 1)" nRet, container_data = m3.QueryDataObject(strLuaDEID, "JX_TO_Detail", strCondition) lua.Debug(strLuaDEID, debug.getinfo(1), "container_data--->", container_data) -- 检查查询结果 if (nRet ~= 0 or container_data == '') then result.success = false result.errMsg = "没有找到数据!" lua.Warning(strLuaDEID, debug.getinfo(1), "查询失败: " .. result.errMsg) return 200, result.errMsg end -- 用来存储合并后的数据 local merged_data = {} local cell_no, item_code, item_name, qty, weight, volume -- 遍历查询到的每条数据 for i = 1, #container_data do local record = m3.KeyValueAttrsToObjAttr(container_data[i].attrs) local cell_no = record.S_CELL_NO -- 获取料格号 item_code = record.S_ITEM_CODE -- 获取物料编码 item_name = record.S_ITEM_NAME qty = lua.Get_NumAttrValue(record.F_QTY) -- 获取数量 weight = lua.Get_NumAttrValue(record.F_WEIGHT) -- 获取重量 volume = lua.Get_NumAttrValue(record.F_VOLUME) -- 获取体积 local no = record.S_TO_NO --移库单号 local key = cntr_code .. "_" .. cell_no .. "_" .. item_code -- 检查该键是否已经存在于合并的数据表中 if merged_data[key] then -- 如果已经存在,累加数据 merged_data[key].qty = merged_data[key].qty + qty merged_data[key].weight = merged_data[key].weight + weight merged_data[key].volume = merged_data[key].volume + volume else -- 否则,创建一个新记录并保存 merged_data[key] = { cell_no = cell_no, item_code = item_code, item_name = item_name, qty = qty, weight = weight, volume = volume } end -- 合并CG_Detail明细的时候,更改状态值为完成2 strUpdateSql = "N_B_STATE = 2" strCondition = "S_NO = '"..no.."'" nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "JX_Transfer_Order", strCondition, strUpdateSql ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "更新【JX_Transfer_Order】信息失败!"..strRetInfo ) end end lua.Debug(strLuaDEID, debug.getinfo(1), "Merged Data--->", merged_data) -- 遍历合并后的数据,插入新记录 for _, merged_record in pairs(merged_data) do local nRet,batch_no = jx_base.Generate_Batch_No(merged_record.item_code) if ( nRet ~= 0 ) then return 200, batch_no end lua.Debug(strLuaDEID, debug.getinfo(1), "batch_no--->", batch_no) local cg_detail = m3.AllocObject(strLuaDEID, "CG_Detail") cg_detail.cntr_code = cntr_code cg_detail.cell_no = merged_record.cell_no cg_detail.item_code = merged_record.item_code cg_detail.item_name = merged_record.item_name cg_detail.batch_no = batch_no cg_detail.qty = merged_record.qty cg_detail.weight = merged_record.weight cg_detail.volume = merged_record.volume nRet, cg_detail = m3.CreateDataObj(strLuaDEID, cg_detail) lua.Debug(strLuaDEID, debug.getinfo(1), "Create Result--->", cg_detail) if (nRet ~= 0) then result.success = false result.errMsg = "插入【CG_Detail】记录失败!" lua.Warning(strLuaDEID, debug.getinfo(1), "Insert operation failed: " .. result.errMsg) return 200, result.errMsg end end return 0, "成功合并容器数据" end -- 设置CG_Detail中的批次号 local function reset_cg_detial_batch_no( strLuaDEID, cntr_code ) local nRet, strRetInfo, n local strCondition, strSetAttr local data_objs strCondition = "S_CNTR_CODE = '"..cntr_code.."'" nRet, data_objs = m3.QueryDataObject(strLuaDEID, "CG_Detail", strCondition, "S_CELL_NO" ) if ( nRet ~= 0 ) then return 2, "QueryDataObject失败!"..data_objs end if ( data_objs == '' ) then return 0 end local cg_detail, batch_no for n = 1, #data_objs do cg_detail = m3.KeyValueAttrsToObjAttr(data_objs[n].attrs) nRet, batch_no = jx_base.Generate_Batch_No( cg_detail.S_ITEM_CODE ) if ( nRet ~= 0 ) then return 2, batch_no end strCondition = "S_ID = '"..data_objs[n].id.."'" strSetAttr = "S_BATCH_NO = '"..batch_no.."'" nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "CG_Detail", strCondition, strSetAttr ) if ( nRet ~= 0 ) then return 2, "更新【CG_Detail】信息失败!"..strRetInfo end end return 0 end -- 【初始巨沃料箱货品】处理 local function jw_cntr_goods_init_process( strLuaDEID, station, cntr_code ) local nRet, strRetInfo local operation local cntr if ( StrIsEmpty( cntr_code ) ) then return 1, "jw_cntr_goods_init_process 函数 cntr_code 不能为空!" end nRet, cntr = wms_cntr.GetInfo( strLuaDEID, cntr_code ) if ( nRet ~= 0 ) then return 200, cntr end -- 重置容器的空满和基础信息 wms_cntr.Reset( strLuaDEID, cntr ) -- 设置CG_Detail中的批次号 nRet, strRetInfo = reset_cg_detial_batch_no( strLuaDEID, cntr_code ) if ( nRet ~= 0 ) then return 200, "设置CG_Detail批次信息时失败!"..strRetInfo end -- 这种作业类型会根据 CG_Detail 里的货品数量 + 货品量表 local ext_info = { bs_type = "JW_CNTR_Goods_INIT", bs_no = cntr_code } nRet, operation = jx_base.Create_StorageOperation( strLuaDEID, "巨沃", station, cntr_code, "初始入库", ext_info ) if ( nRet ~= 0 ) then err_code = 203 msg = "创建码盘入库作业失败!".. operation lua.Warning( strLuaDEID, debug.getinfo(1), "WCS调用WMS料箱入库接口失败: "..msg ) return err_code, msg end -- 【注意】如果上面的程序有入库作业产生需要对入库作业的终点货位加入库锁 nRet, strRetInfo = wms.wms_LockLocation(strLuaDEID, operation.end_loc_code, wms_base.Get_nConst( strLuaDEID, "锁类型-入库锁" ), "", operation.code, operation.op_def_name ) if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "wms_LockLocation 失败!"..strRetInfo ) end return 0, operation end function BoxStorage ( strLuaDEID ) local nRet, strRetInfo, nCount local body local err_code = 0 local msg = "success" local station_obj local requestPk, cntr_code, station, task_code local operation local start_loc local ext_info = {} local jx_task, data_objs, obj_attrs local toPos = '' local state, roadway_in_loc, end_loc_code local cntr, task_attrs local go_up = false local stacker_dev -- 获取接口传入的数据 nRet, body = m3.GetSysDataJson(strLuaDEID) if ( nRet ~= 0 ) then err_code = 200 lua.Warning( strLuaDEID, debug.getinfo(1), "WCS调用WMS扫码入库接口失败: 输入参数的格式有问题!"..body ) msg = "输入参数的格式有问题!" goto api_call_return end lua.Debug( strLuaDEID, debug.getinfo(1), "body--->", body ) requestPk = lua.Get_StrAttrValue( body.requestPk ) cntr_code = lua.Get_StrAttrValue( body.containerCode ) station = lua.Get_StrAttrValue( body.curPos ) task_code = lua.Get_StrAttrValue( body.taskNo ) if ( requestPk == '') then err_code = 201 lua.Warning( strLuaDEID, debug.getinfo(1), "WCS调用WMS扫码入库接口失败: 输入参数有问题! requestPk 必须有值" ) msg = "requestPk 必须有值" goto api_call_return end if ( cntr_code == '') then err_code = 201 lua.Warning( strLuaDEID, debug.getinfo(1), "WCS调用WMS扫码入库接口失败: 输入参数有问题! containerCode 必须有值!" ) msg = "contNo 必须有值!" goto api_call_return end if ( station == '') then err_code = 201 lua.Warning( strLuaDEID, debug.getinfo(1), "WCS调用WMS扫码入库接口失败: 输入参数有问题! curPos 必须有值!" ) msg = "curPos 必须有值!" goto api_call_return end -- 获取扫码点站台信息 nRet, station_obj = jx_base.Get_Station_ExtData( strLuaDEID, station ) if ( nRet ~= 0 ) then err_code = 202 msg = station_obj lua.Warning( strLuaDEID, debug.getinfo(1), "WCS调用WMS扫码入库接口失败: 输入参数有问题! "..msg ) goto api_call_return end -- 获取起点货位 nRet, start_loc = wms_wh.GetLocInfo( station_obj.loc_code ) if ( nRet ~= 0 ) then err_code = 202 msg = start_loc lua.Warning( strLuaDEID, debug.getinfo(1), "WCS调用WMS扫码入库接口失败: 输入参数有问题! "..msg ) goto api_call_return end -- 确定容器是否存在 nRet, cntr = wms_cntr.GetInfo( strLuaDEID, cntr_code ) if ( nRet ~= 0 ) then err_code = 202 msg = "检查容器是否存在时失败! "..cntr lua.Warning( strLuaDEID, debug.getinfo(1), "WCS调用WMS扫码入库接口失败: "..msg ) goto api_call_return end if ( cntr == '' ) then err_code = 203 msg = "容器编码 = '".. cntr_code.."'的容器不存在!" lua.Warning( strLuaDEID, debug.getinfo(1), "WCS调用WMS扫码入库接口失败: "..msg ) goto api_call_return end -- V4.0 MDF BY HAN @20241219 判断一下容器是否已经有作业启动, 扫码点有一个环穿,经扫码点的容器也有可能是有作业的 if ( task_code ~= '' ) then -- Task 已经存在说明这个任务已经是有创建过作业 nRet, task = wms_task.GetInfo( strLuaDEID, task_code ) if ( nRet > 1 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取【任务】信息失败!"..task ) end if ( nRet == 1 ) then err_code = 210 msg = "编码 = '".. task_code.."'的任务不存在!" lua.Warning( strLuaDEID, debug.getinfo(1), "WCS调用WMS扫码入库接口失败: "..msg ) goto api_call_return end -- 获取任务所属的作业对象 nRet, operation = wms_op.GetInfo( strLuaDEID, task.op_code ) if ( nRet > 1 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取【作业】信息失败!"..operation ) end if ( nRet == 1 ) then err_code = 210 msg = "编码 = '".. task.op_code.."'的作业不存在!" lua.Warning( strLuaDEID, debug.getinfo(1), "WCS调用WMS扫码入库接口失败: "..msg ) goto api_call_return end -- BY KUN 判断作业名称是不是巨星作业的站台搬运类型,如果是的话,就用原来的位置,跳出 if (operation.op_def_name == '站台搬运' )then toPos = operation.end_loc_code goto api_call_return end -- 已存在的作业,需要重新计算货位, 有两种情况 1# 巨沃的入库任务,2# 就是巨星任务经过循环输送线再次进入扫码点 -- 重新计算一个入库货位 nRet, roadway_in_loc, end_loc_code = jx_base.Get_StorageCache_Loc( strLuaDEID, station ) if ( nRet ~= 0 ) then if ( nRet == 1 ) then -- 还是老位置 toPos = task.end_loc_code goto api_call_return end err_code = 213 msg = "计算立库存储货位失败".. roadway_in_loc lua.Warning( strLuaDEID, debug.getinfo(1), "WCS调用WMS扫码入库接口失败: "..msg ) goto api_call_return end -- 改变任务去向 toPos = roadway_in_loc if ( task.end_loc_code ~= toPos ) then -- 如果 原来的任务终点不一样, 改任务终点货位 -- V7.1 加改进任务巷道信息 -- 获取终点货位信息 nRet, end_loc = wms_wh.GetLocInfo( toPos ) if ( nRet ~= 0 ) then err_code = 202 msg = end_loc lua.Warning( strLuaDEID, debug.getinfo(1), "WCS调用WMS扫码入库接口失败: 输入参数有问题! "..msg ) goto api_call_return end strUpdateSql = "S_END_LOC = '"..toPos.."', N_END_LANE = "..end_loc.roadway strCondition = "S_CODE = '"..task_code.."'" nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Task", strCondition, strUpdateSql ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "更新【任务】信息失败!"..strRetInfo ) end end if ( operation.end_loc_code ~= end_loc_code ) then nRet, strRetInfo = wms.wms_UnlockByOperation( strLuaDEID, operation.code) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "解锁失败!"..strRetInfo ) end strUpdateSql = "S_END_LOC = '"..end_loc_code.."'" strCondition = "S_CODE = '"..operation.code.."'" nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Operation", strCondition, strUpdateSql ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "更新【作业】信息失败!"..strRetInfo ) end -- 给新的终点货位加入库锁 nRet, strRetInfo = wms.wms_LockLocation(strLuaDEID, end_loc_code, wms_base.Get_nConst( strLuaDEID, "锁类型-入库锁" ), "", operation.code, operation.op_def_name ) if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "wms_LockLocation 失败!"..strRetInfo ) end end goto api_call_return end -- 判断扫码的容器是巨星相关入库,还是处理料箱初始化,还是 巨沃相关入库作业 -- V2.0 MDF BY HAN @20241130 增加对【巨星作业】任务池的判断 strCondition = "S_CNTR_CODE = '"..cntr_code.."' AND ( N_B_STATE = 0 or N_B_STATE = 1 )" nRet, data_objs = m3.QueryDataObject(strLuaDEID, "JX_Task", strCondition ) if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1),"QueryDataObject失败!"..data_objs ) end if ( data_objs == '' ) then -- 判断是否在【JX_ASRS_EmptyBox_In】自动化立库空料箱初始化表 strCondition = "S_CNTR_CODE = '"..cntr_code.."'" nRet, data_objs = m3.QueryDataObject(strLuaDEID, "JX_ASRS_EmptyBox_In", strCondition ) if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1),"QueryDataObject失败!"..data_objs ) end if ( data_objs == '' ) then -- V4.0 判断是否在【初始巨沃料箱货品】 strCondition = "S_CNTR_CODE = '"..cntr_code.."'" nRet, data_objs = m3.QueryDataObject(strLuaDEID, "JW_CNTR_Goods_INIT", strCondition ) if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1),"QueryDataObject失败!"..data_objs ) end if ( data_objs == '' ) then err_code = 210 msg = "料箱编码 = '".. cntr_code.."' 没有找到可执行任务!(巨沃)" lua.Warning( strLuaDEID, debug.getinfo(1), "WCS调用WMS扫码入库接口失败: "..msg ) goto api_call_return else nRet, operation = jw_cntr_goods_init_process( strLuaDEID, station, cntr_code ) if ( nRet ~= 0 ) then err_code = 211 msg = "料箱编码 = '".. cntr_code.."' 在处理初始巨沃料箱货品入库时失败!"..operation lua.Warning( strLuaDEID, debug.getinfo(1), "WCS调用WMS扫码入库接口失败: "..msg ) end toPos = operation.ext_data -- 作业这里会有接驳位信息 goto api_call_return end else -- 空料箱初始化操作 ext_info = { bs_type = "JX_ASRS_EmptyBox_In", bs_no = cntr_code } nRet, operation = jx_base.Create_StorageOperation( strLuaDEID, "杭叉", station, cntr_code, "空箱入库", ext_info ) if ( nRet ~= 0 ) then err_code = 203 msg = "创建料箱入库作业失败!".. operation lua.Warning( strLuaDEID, debug.getinfo(1), "WCS调用WMS料箱入库接口失败: "..msg ) goto api_call_return end toPos = operation.ext_data -- 作业这里会有接驳位信息 -- 【注意】如果上面的程序有入库作业产生需要对入库作业的终点货位加入库锁 nRet, strRetInfo = wms.wms_LockLocation(strLuaDEID, operation.end_loc_code, wms_base.Get_nConst( strLuaDEID, "锁类型-入库锁" ), "", operation.code, operation.op_def_name ) if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "wms_LockLocation 失败!"..strRetInfo ) end end else if ( #data_objs > 1 ) then err_code = 203 msg = "任务池里有多个容器编码='".. cntr_code.."'的未执行完成任务,请先处理这些不合法的数据!" lua.Warning( strLuaDEID, debug.getinfo(1), "WCS调用WMS扫码入库接口失败: "..msg ) goto api_call_return end obj_attrs = m3.KeyValueAttrsToObjAttr(data_objs[1].attrs) state = lua.Get_NumAttrValue( obj_attrs.N_B_STATE ) if ( obj_attrs.S_TASK_TYPE ~= '入库' ) then err_code = 203 msg = "任务池中容器编码='".. cntr_code.."'的任务不是入库任务" lua.Warning( strLuaDEID, debug.getinfo(1), "WCS调用WMS扫码入库接口失败: "..msg ) goto api_call_return end if ( state == 1 ) then err_code = 203 msg = "任务池中容器编码='".. cntr_code.."'的任务已经启动!" lua.Warning( strLuaDEID, debug.getinfo(1), "WCS调用WMS扫码入库接口失败: "..msg ) goto api_call_return end -- V4.0 MDF BY HAN 如果去3,4楼的巨星任务只能是16120扫码点 -- V8.0 if ( obj_attrs.S_SOURCESYS == "GSWMS" ) then if ( obj_attrs.S_END_AREA == AREA_3_FLOOR or obj_attrs.S_END_AREA == AREA_4_FLOOR ) then if ( station ~= CAN_TO_3_4_FLOOR_STATION ) then err_code = 210 msg = "任务='".. obj_attrs.S_SOURNO.."'的任务只能是通过'"..CAN_TO_3_4_FLOOR_STATION.."'扫码点上3,4楼!" lua.Warning( strLuaDEID, debug.getinfo(1), "WCS调用WMS扫码入库接口失败: "..msg ) goto api_call_return end if ( obj_attrs.S_END_AREA == AREA_3_FLOOR ) then end_loc_code = LOC_3_FLOOR else end_loc_code = LOC_4_FLOOR end ext_info = { bs_type = "JX-Task", bs_no = obj_attrs.S_SOURNO, lock_cntr = 'N', source_sys = "巨星" } nRet, operation = wms_op.Create( strLuaDEID, cntr_code, station, end_loc_code, wms_base.Get_nConst(strLuaDEID, "作业类型-入库"), "站台搬运", ext_info ) if ( nRet ~= 0 ) then err_code = 203 msg = "创建巨星入库作业失败!".. operation lua.Warning( strLuaDEID, debug.getinfo(1), "WCS调用WMS扫码入库接口失败: "..msg ) goto api_call_return end toPos = end_loc_code else ext_info = { bs_type = "JX-Task", bs_no = obj_attrs.S_SOURNO } nRet, operation = jx_base.Create_StorageOperation( strLuaDEID, "巨星", station, cntr_code, "巨星入库", ext_info ) if ( nRet ~= 0 ) then err_code = 203 msg = "创建巨星入库作业失败!".. operation lua.Warning( strLuaDEID, debug.getinfo(1), "WCS调用WMS扫码入库接口失败: "..msg ) goto api_call_return end toPos = operation.ext_data -- 作业这里会有接驳位信息 -- 进立库终点货位要加入库锁 nRet, strRetInfo = wms.wms_LockLocation(strLuaDEID, operation.end_loc_code, wms_base.Get_nConst( strLuaDEID, "锁类型-入库锁" ), "", operation.code, operation.op_def_name ) if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "wms_LockLocation 失败!"..strRetInfo ) end end elseif (obj_attrs.S_SOURCESYS == "巨沃") then ext_info = { bs_type = "JX-Task", bs_no = obj_attrs.S_SOURNO } -- 调用合并函数,合并相同的容器号、料格号、物料编码的数据 local nRet, mergeResult = CG_detail_Merge(strLuaDEID, cntr_code) if (nRet ~= 0) then err_code = 204 msg = "合并容器数据失败: " .. mergeResult lua.Warning(strLuaDEID, debug.getinfo(1), "容器数据合并失败: " .. msg) goto api_call_return end -- 合并完成后,继续创建巨沃入库作业 nRet, operation = jx_base.Create_StorageOperation(strLuaDEID, "巨沃", station, cntr_code, "码盘入库", ext_info) if (nRet ~= 0) then err_code = 203 msg = "创建巨沃入库作业失败!" .. operation lua.Warning(strLuaDEID, debug.getinfo(1), "WCS调用WMS扫码入库接口失败: " .. msg) goto api_call_return end toPos = operation.ext_data -- 作业这里会有接驳位信息 -- 进立库终点货位要加入库锁 nRet, strRetInfo = wms.wms_LockLocation(strLuaDEID, operation.end_loc_code, wms_base.Get_nConst(strLuaDEID, "锁类型-入库锁"), "", operation.code, operation.op_def_name) if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "wms_LockLocation 失败!" .. strRetInfo) end elseif(obj_attrs.S_SOURCESYS == "巨沃入库") then ext_info = { bs_type = "JX-Task", bs_no = obj_attrs.S_SOURNO } nRet, operation = jx_base.Create_StorageOperation(strLuaDEID, "巨沃", station, cntr_code, "料箱入库", ext_info) if (nRet ~= 0) then err_code = 203 msg = "创建巨沃入库作业失败!" .. operation lua.Warning(strLuaDEID, debug.getinfo(1), "WCS调用WMS扫码入库接口失败: " .. msg) goto api_call_return end toPos = operation.ext_data -- 作业这里会有接驳位信息 -- 进立库终点货位要加入库锁 nRet, strRetInfo = wms.wms_LockLocation(strLuaDEID, operation.end_loc_code, wms_base.Get_nConst(strLuaDEID, "锁类型-入库锁"), "", operation.code, operation.op_def_name) if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "wms_LockLocation 失败!" .. strRetInfo) end else lua.Error( strLuaDEID, debug.getinfo(1), "【巨星任务】中的字段S_SOURCESYS必须有值!" ) end -- N_B_STATE = 1 任务执行 strUpdateSql = "N_B_STATE = 1, S_OP_CODE = '"..operation.code.."'" strCondition = "S_SOURNO = '"..obj_attrs.S_SOURNO.."'" nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "JX_Task", strCondition, strUpdateSql ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "更新【巨星任务】信息失败!"..strRetInfo ) end end ::api_call_return:: -- 设置返回结果 local result = { code = err_code, msg = msg, toPos = toPos, -- 在扫码点重新分配的货位 requestPk = body.requestPk } m3.EPI_Return( strLuaDEID, result ) lua.Debug( strLuaDEID, debug.getinfo(1), "result--->", result ) end